package com.ityedao.接口案例;

import java.util.ArrayList;

public class StudentOperatorImpl1 implements StudentOperator{
    @Override
    public void printAllInfo(ArrayList<Student> students) {
        System.out.println("-----------全班信息如下------------");
        for (int i = 0; i < students.size(); i++) {
            Student s = students.get(i);
            System.out.println("姓名：" + s.getName() + "性别：" + s.getSex() + "分数：" + s.getScore());
        }
    }

    @Override
    public void printAverageScore(ArrayList<Student> students) {
        System.out.println("-----------全班平均成绩如下-------------");
        double allScores = 0;
        for (int i = 0; i < students.size(); i++) {
            Student s = students.get(i);
            allScores += s.getScore();
        }
        System.out.println("全班平均成绩：" + (allScores / students.size()));
    }
}
